window.onload=function () {
    //设置图片高度
    var liWidth = $('li img').width();
    $('li').css('height',liWidth);
    var imgHeight = $('li img').height();
    $('li img').css('margin-top',(liWidth-imgHeight)/2);
    var liLength = $('li').length;
    if(liLength%4!=0){
        console.log(liLength%4);
        var addLength = liLength%4;
        for(var i=0;i<addLength;i++){
            $('<li style="height: '+liWidth+'px"></li>').appendTo($('#brand_box'))
        }
    }
}

//
var hrefId = GetQueryString('hrefId');
var page = 1;
$(function () {
    doAjax("/goodsCategoryC/type2.json", page, "", ".brand_small_box", callBack);
})

function callBack(data) {
    if(data.code==1){
        if(page==1){
            $('.brand_small_box').empty();
        }
        var brandData = data.datas;
        for(var i=0;i<brandData.length;i++){
            $('<h3 class="brand_small_title mui-clearfix" id="'+brandData[i].id+'">' +
                '<span></span><small>'+brandData[i].name+'</small><span>' +
                '</div></span></h3>' +
                '<div class="brand_img_box mui-clearfix"><ul id="brand_box'+brandData[i].id+'"></ul></div>').appendTo($('.brand_small_box'))
            var threeData = brandData[i].thirdCategory;
            for(var k=0;k<threeData.length;k++){
                $('<li><img src="'+threeData[k].imgUrl+'" alt=""></li>').appendTo($('#brand_box'+brandData[i].id+''))
            }
        }
        var scrollTop = $('#'+hrefId+'').offset().top;
        document.body.scrollTop = document.documentElement.scrollTop = scrollTop;
    }
}